﻿<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
	<meta http-equiv="Cache-Control" content="no-siteapp" />		
	{include file="public/css"}
	<title>考级考牌</title>
</head>
<body>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i>首页<span class="c-gray en">&gt;</span>
		收费标准
		<span class="c-gray en">&gt;</span>
		{$type}
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新">
			<i class="Hui-iconfont">&#xe68f;</i>
		</a>
	</nav>
	<div class="page-container">
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<!-- <span class="l">
				<a href="javascript:;" class="btn btn-danger radius delAll">
					<i class="Hui-iconfont">&#xe6e2;</i>
					批量删除
				</a>
				<a class="btn btn-primary radius cardAdd" href="javascript:;" data-id="" data-name="" data-money="">
					<i class="Hui-iconfont">&#xe600;</i>
					添加考级
				</a>
			</span> -->
			<span class="r">
				共有数据：<strong>{:count($list)}</strong>条
			</span>
		</div>
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
				<thead>
					<tr class="text-c">
						<th width="25"><input type="checkbox" value=""></th>
						<th width="50">ID</th>
						<th>等级</th>
						<th>费用</th>
						<!-- <th>操作</th> -->
					</tr>
				</thead>
				<tbody>
					{volist name="list" id="n"}
					<tr class="text-c">
						<td>
							<input type="checkbox" name="ids" value="{$n.id}">
						</td>
						<td>{$n.id}</td>
						<td>{$n.name}</td>
						<td>{$n.money}</td>
						<!-- <td class="f-14 td-manage">
							<a style="text-decoration:none" class="ml-5 cardAdd" href="javascript:;" title="编辑" data-id="{$n.id}" data-name="{$n.name}" data-money="{$n.money}">
								<i class="Hui-iconfont">&#xe6df;</i>
							</a>
							<a style="text-decoration:none" class="ml-5 del" href="javascript:;" data-id="{$n.id}" title="删除">
								<i class="Hui-iconfont">&#xe6e2;</i>
							</a>
						</td> -->
					</tr>
					{/volist}
				</tbody>
			</table>
		</div>
	</div>
	<!--_footer 作为公共模版分离出去-->	
	{include file="public/js"}
	<!--/_footer 作为公共模版分离出去-->
	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript" src="/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript">
		function del(id){
			var index=layer.confirm('确定删除数据？',{btn:['确定','取消']},function(){
				layer.close(index);
				$.post("{:url('del')}",{id:id,sql:'card',img:''},function(res){
					if (res.state==200) {
						layer.msg(res.msg,{icon:1},function(){
							window.location.reload();
						})
					}else{
						layer.msg(res.msg,{icon:2,time:1500});
					}
				})
			})
		}
		$(".delAll").click(function(){
			var ids='';
			$("input[name=ids]:checked").each(function(){
				if (ids!='') {
					ids+=','+$(this).val();
				}else{
					ids=$(this).val();
				}
			})
			if (ids!='') {
				del(ids);
			}else{
				layer.msg('请选择要删除的数据',{icon:7,time:1500});
			}
		})
		$(".del").click(function(){
			var id=$(this).attr('data-id');
			del(id);
		})

		$(".cardAdd").click(function(){
			var id=$(this).attr("data-id");
				name=$(this).attr("data-name");
				money=$(this).attr("data-money");
				type="{$type}";
			id!=''?title='考级编辑':title='添加考级';
			html="<form><div style='color:#000;position:absolute;top:50%;height:30%;width: 50%;margin: -10% 0 0 25%;'>考牌等级<input type='text' name='name' value='"+name+"'></div><div style='color:#000;position:absolute;top:50%;width:50%;margin: 0 0 0 25%;'>报名费用<input type='text' name='money' value='"+money+"'><input type='hidden' name='id' value='"+id+"'></div></form>";
			var index=layer.open({
					type: 1,
					title: title,
					skin: 'layui-layer-rim', //加上边框
					area: ['420px', '240px'], //宽高
					btn:['确定','取消'],
					content: html,
					yes: function(){
						var type=$("select[name=type]").find("option:selected").val();
							name=$("input[name=name]").val();
							money=$("input[name=money]").val();
							id = $("input[name=id]").val();
						if (name=='' || money=='')  {
							layer.msg('请输入完整信息',{icon:7,time:1500});
						}else{
							$.post("{:url('card')}",{id:id,name:name,money:money,type:type},function(res){
								layer.close(index);
								//console.log(res)
								if (res.code==200) {									
									layer.msg(res.msg,{icon:1,time:1500},function(){
										location.replace(location.href);
									});
								}else{
									layer.msg(res.msg,{icon:2,time:1500});
								}
							})
						}
					}
				});
		})
	</script>
</body>
</html>